#include <stdio.h>
#include <string.h>
#include <math.h>

int function_1(int a, int b)
{
	int i = 0, min = 0, max = 0, tmp = 0;
	max = (a > b) ? a : b;
	min = (a < b) ? a : b;
	if (max%min == 0)
		return min;
	for(i=1; i<min/2; i++)
	{
		if (min%i == 0 && max%i == 0)
			tmp = i;
	}
	return tmp;
}

int function_2(int a, int b)//欧基里德算法
{
	int max =0, min = 0, tmp = 0;
	max = (a > b) ? a : b;
	min = (a < b) ? a : b;
	tmp = max % min;
	if (tmp == 0)
		return min;
	function_2(min, tmp);
}

int function_3(int a, int b)
{
	int max = 0, min = 0, tmp = 0, i = 1 , len = 0;
	max = (a > b) ? a : b;
	min = (a < b) ? a : b;
	len = sqrt(min);
	while (i<=len)
	{
		if (min%i == 0)
			tmp = min/i;
		if (max%tmp == 0)
		{
			return tmp;
			break;
		}
		i++;
	}
}

int main()
{
	int a, b;
	printf("please input a!\n");
	scanf("%d", &a);
	printf("please input b!\n");
	scanf("%d", &b);
	printf("the maxys: %d\n", function_1(a, b));
	printf("the maxys: %d\n", function_2(a, b));
	printf("the maxys: %d\n", function_3(a, b));
	return 0;
}
